package com.example.demo.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

/**
 * 　* @description: 拦截器配置类
 *
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private AppInterceptor appInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> urls = new ArrayList<>();

        /********测试**********/
        urls.add("/home/welcome");

        /** 处理swagger-ui路径 **/
        urls.add("/swagger-ui.html");
        urls.add("/swagger-ui.html/**");
        urls.add("/swagger-resources/**/");
        urls.add("/v2/api-docs");
        urls.add("/error");
        urls.add("/webjars/**");
        urls.add("/webjars/springfox-swagger-ui/**");
        urls.add("/webjars/springfox-swagger-ui/css/typography.css");
        urls.add("/configuration/ui");
        urls.add("/configuration/security");
        urls.add("/**/favicon.ico");
        //添加拦截器
        registry.addInterceptor(appInterceptor).excludePathPatterns(urls);
    }
}
